package bavaria.hightech.testit;


import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;

import bavaria.hightech.b2b.BankRegistry;
import bavaria.hightech.b2b.IB2B;
import bavaria.hightech.banking.BankImpl;
import bavaria.hightech.timer.InternalClock;

import static org.junit.Assert.*;


public class BankRegistryUnitTest {
	private static InternalClock timer;
	private IB2B bank1;
	private IB2B bank2;
	private BankRegistry registry1;
	private BankRegistry registry2;

	
	@BeforeClass
	public static void setUpBeforeClass() throws Exception {
		
	}

	@AfterClass
	public static void tearDownAfterClass() throws Exception {
	}

	@Before
	public void setUp() throws Exception {
		timer = InternalClock.getInstance();
		bank1 = new BankImpl("de", "de");
		bank2 = new BankImpl("en", "uk");
		registry1 = BankRegistry.getInstance();
		registry2 = BankRegistry.getInstance();
	}

	@After
	public void tearDown() throws Exception {
	}

	
	@Test
	public void testBankRegistrySingleton(){
		assertTrue(registry1==registry2);
	}
	
	@Test
	public void testBindAndLookup(){
		registry1.bind("bank1", bank1);
		registry1.bind("bank2", bank2);
		registry2.bind("bank1", bank1);
		registry2.bind("bank2", bank2);
		assertEquals(registry1.lookup("bank1"), bank1);
		assertEquals(registry2.lookup("bank2"), bank2);


	}
}
